﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using CTEM.Models;
using CTEM.Controllers.BUS;

namespace CTEM.ModuleForms.ManageReport
{
    public partial class LedgerReport : DevExpress.XtraBars.Ribbon.RibbonForm
    {

        private LedgerReportSetting ledgerReportSetting;
        private LedgerDTO lerger;
        private List<LedgerDTO> listLedger;
        private LedgerBUS ledBus = new LedgerBUS();
        public LedgerReport()
        {
            InitializeComponent();
            ledgerReportSetting = new LedgerReportSetting();
            ledgerReportSetting.Show();
            ledgerReportSetting.AskInformationChanged += new LedgerReportSetting.InformationLedgerDelegate(loadData);
        }
        public void loadData(long kindID, string type, DateTime Fromday, DateTime ToDay)
        {
            if (kindID == -1)
                listLedger = ledBus.loadLergerforAllReport(type,Fromday,ToDay);
            else
                listLedger = ledBus.loadLergerforReport(kindID, type, Fromday, ToDay);
            XtraLedgerReport report = new XtraLedgerReport();
            report.DataBind(listLedger, Fromday, ToDay);

            printControl1.PrintingSystem = report.PrintingSystem;
            report.CreateDocument();
        
        }
        

        private void bReportSetting_ItemClick(object sender, ItemClickEventArgs e)
        {
            ledgerReportSetting.Visible = true;
        }

        private void LedgerReport_FormClosing(object sender, FormClosingEventArgs e)
        {
            ledgerReportSetting.Enabled = false;
        }
    }
}